<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Sugar</title>
</head>

<body>
  <h1>字符串替换 replace</h1>
  <script>
    let htmlStr = `<div class=\"lazyimg\"><p>
        <img class=\"rich_image\" data-src=\"https://image.suning.cn/uimg/sop/commodity/467635356650778522320000_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"小米关联推荐_02\" usemap=\"#详情关联11\" border=\"0\" src=\"https://image.suning.cn/uimg/sop/commodity/467635356650778522320000_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\"></p>\n<p> </p>\n<p> </p>\n<p></p><div class=\"player\" data-name=\"prodDetail_none_main_xqspdj\" data-name2=\"prodDetail_none_main_xqspbg\"><div id=\"playBox\" class=\"player-box\"></div></div><div moduleid=\"R0503002_1\" modulename=\"优惠信息\"><p>
        <img class=\"rich_image\" data-src=\"https://image.suning.cn/uimg/sop/commodity/624580955141631442816500_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"https://image.suning.cn/uimg/sop/commodity/624580955141631442816500_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\">
        <img class=\"rich_image\" data-src=\"https://image.suning.cn/uimg/sop/commodity/750257134173360899183920_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"https://image.suning.cn/uimg/sop/commodity/750257134173360899183920_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\"></p></div><div moduleid=\"R0503002_2\" modulename=\"关联推荐\"><p>
        <img class=\"rich_image\" data-src=\"//image.suning.cn/uimg/sop/commodity/593261775122128320495900_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"4A-55英寸标配和高配-\" usemap=\"#对比对比1\" border=\"0\" src=\"//image.suning.cn/uimg/sop/commodity/593261775122128320495900_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\"> </p></div><div moduleid=\"R0503002_3\" modulename=\"商品详情\"><p>
        <img class=\"rich_image\" data-src=\"//image.suning.cn/uimg/sop/commodity/872614526112700960762920_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"//image.suning.cn/uimg/sop/commodity/872614526112700960762920_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\">
        <img class=\"rich_image\" data-src=\"//image.suning.cn/uimg/sop/commodity/178057545629819716628620_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"//image.suning.cn/uimg/sop/commodity/178057545629819716628620_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\">
        <img class=\"rich_image\" data-src=\"//image.suning.cn/uimg/sop/commodity/380256286188203360340300_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"//image.suning.cn/uimg/sop/commodity/380256286188203360340300_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\">
        <img class=\"rich_image\" data-src=\"//image.suning.cn/uimg/sop/commodity/167444193535900960747020_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"//image.suning.cn/uimg/sop/commodity/167444193535900960747020_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\">
        <img class=\"rich_image\" data-src=\"//image.suning.cn/uimg/sop/commodity/190702461512075692226088_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"//image.suning.cn/uimg/sop/commodity/190702461512075692226088_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\">
        <img class=\"rich_image\" data-src=\"//image.suning.cn/uimg/sop/commodity/193225708920132925116800_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"//image.suning.cn/uimg/sop/commodity/193225708920132925116800_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\">
        <img class=\"rich_image\" data-src=\"//image.suning.cn/uimg/sop/commodity/100234645823384546020570_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"//image.suning.cn/uimg/sop/commodity/100234645823384546020570_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\">
        <img class=\"rich_image\" data-src=\"//image.suning.cn/uimg/sop/commodity/134244508914681730413221_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"//image.suning.cn/uimg/sop/commodity/134244508914681730413221_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\">
        <img class=\"rich_image\" data-src=\"//image.suning.cn/uimg/sop/commodity/143584524217063886387316_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"//image.suning.cn/uimg/sop/commodity/143584524217063886387316_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\">
        <img class=\"rich_image\" data-src=\"//image.suning.cn/uimg/sop/commodity/513470462407471276209000_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"//image.suning.cn/uimg/sop/commodity/513470462407471276209000_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\">
        <img class=\"rich_image\" data-src=\"//image.suning.cn/uimg/sop/commodity/768155845191100645818580_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"//image.suning.cn/uimg/sop/commodity/768155845191100645818580_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\">
        <img class=\"rich_image\" data-src=\"//image.suning.cn/uimg/sop/commodity/380665032256939613426000_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"//image.suning.cn/uimg/sop/commodity/380665032256939613426000_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\">
        <img class=\"rich_image\" data-src=\"//image.suning.cn/uimg/sop/commodity/353945991085129704393300_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"//image.suning.cn/uimg/sop/commodity/353945991085129704393300_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\">
        <img class=\"rich_image\" data-src=\"//image.suning.cn/uimg/sop/commodity/164864070417089503504147_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"//image.suning.cn/uimg/sop/commodity/164864070417089503504147_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\">
        <img class=\"rich_image\" data-src=\"//image.suning.cn/uimg/sop/commodity/154012630113971530696436_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"//image.suning.cn/uimg/sop/commodity/154012630113971530696436_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\">
        <img class=\"rich_image\" data-src=\"//image.suning.cn/uimg/sop/commodity/114472565711084909029791_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"//image.suning.cn/uimg/sop/commodity/114472565711084909029791_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\">
        <img class=\"rich_image\" data-src=\"//image.suning.cn/uimg/sop/commodity/194376684215165533579335_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"//image.suning.cn/uimg/sop/commodity/194376684215165533579335_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\"></p></div><div moduleid=\"R0503002_6\" modulename=\"安装说明\"><p>
        <img class=\"rich_image\" data-src=\"//image.suning.cn/uimg/sop/commodity/116095146413019169737236_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"//image.suning.cn/uimg/sop/commodity/116095146413019169737236_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\">
        <img class=\"rich_image\" data-src=\"//image.suning.cn/uimg/sop/commodity/581732414126401063654880_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"//image.suning.cn/uimg/sop/commodity/581732414126401063654880_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\"></p></div><p>
        <img class=\"rich_image\" data-src=\"https://image.suning.cn/uimg/sop/commodity/209027813199936384520490_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"小米关联推荐_02\" usemap=\"#详情关联11\" border=\"0\" src=\"https://image.suning.cn/uimg/sop/commodity/209027813199936384520490_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\"></p>\n<p> </p>\n<p> </p>\n<p></p></div>
    `;

    console.log('替换前', htmlStr);

    htmlStr = htmlStr.replace(/webp/g, 'jpg');

    console.log('替换后', htmlStr);

  </script>
</body>

</html>